package com.kwlt.smc.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.kwlt.smc.entity.DateSum;

/**
 * 日期统计量Dao
 * @author wangweiheng
 *
 */

public interface DateSumDao extends PagingAndSortingRepository<DateSum, Long> {
	@Query("select d.userDate,d.operators,sum(d.sendNum),sum(d.successNum) from DateSum d where d.userDate<=:endDate and d.userDate>=:beginDate group by d.userDate,d.operators order by d.userDate,d.operators")
	List findDateSumListAllByDate(@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);
	
	@Query("select d from DateSum d where d.userDate=:userDate")
	List<DateSum> findDateSumAllByDate(@Param("userDate")Date userDate);
	
	@Query("select d from DateSum d where d.userDate=:userDate and d.operators=:operators and d.accessNumber =:accessNumber and d.user =:user")
	DateSum findDateSumByAll(@Param("userDate")Date userDate,@Param("operators")String operators,@Param("accessNumber")String accessNumber,@Param("user")String user);
}
